<meta charset="UTF-8">
<?php
require ('./lib/init.php');
$comment_id = $_GET['comment_id'];
//判断评论是否存在
$sql = "select count(*) from comment where comment_id = $comment_id";
$rs = mGetOne($sql);
if ($rs == 0){
    error ('评论不存在！');
}

//获取当前评论的 文章id
$sql = "select art_id from comment where comment_id = $comment_id";
$art_id = mGetOne($sql);

//删除 comm表中该评论
$sql = "delete from comment where comment_id = $comment_id";
if (!mQuery($sql)){
    error ('删除失败！');
}else{
    //删除成功之后更改art表文章的comm数量
    $sql = "update art set comm = comm - 1 where art_id = $art_id ";
    mQuery($sql);
    $ref = $_SERVER['HTTP_REFERER'];
    header("location:$ref");
}


?>
